/*
*FUJS Javascript library version 1.0 Source code   
*www.fujs.org
*MIT licence
*/

/********************************************************************************************************
******************************************INIT**********************************************************
********************************************************************************************************/

//Language super globals
var $_d=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],
$_m=["January","February","March","April","May","June","July","August","September","October","November","December"],
$_o=["st","nd","rd","th"];

//Math super globals
var $_R2D=180/Math.PI, $_D2R=Math.PI/180, $_PI=Math.PI, $_E=Math.E, $_LN2=Math.LN2, $_LN10=Math.LN10, $_LOG2E=Math.LOG2E, $_LOG10E=Math.LOG10E;

//Window and document super globals
var $_W=window, $_D=$_W.document;

//Error messages super globals
var $_e=["NOT_AN_ARRAY"];



//------------------------------------------------
//-----------------Init Array---------------------
//------------------------------------------------

Array.prototype._=function(key,value){
	
	var arr=this, argLen=arguments.length;
	if(!this.hasOwnProperty('key'))this.key={}
	
	if(arguments.length==0)return false
	
	if(typeof key=="string"){
	
		if(argLen==1)return arr[arr.key[key]]
		
		if(argLen==2){
			if(arr.key[key]){
				var index=arr.key[key]
			}
			else{
				index=arr.length
			}
		
			arr[index]=value
			arr.key[key]=index
		}
			
	}
	
	else{
	
		if(argLen==1){return arr[key]}
		
		if(argLen==2){arr[key]=value}
		
	}
	
};



/********************************************************************************************************
******************************************STRING*********************************************************
********************************************************************************************************/

function asc(str,index){return str.charCodeAt(index)}; //Return asii number of the index letter in str. First letter index=0
function chr(){var a='',i=0,g=arguments;for(;i<g.length;i++)a+=String.fromCharCode(g[i]);return a}; //Returns character of val ascii number 
function echo(val){$_D.write(val)}; //Writes val to the screen
function echon(val){$_D.write(val+"<br/>")};
function join(arr,str_sep){return arr.join(str_sep)}; //Joins an array into a string
function ord(str){return str.charCodeAt(0)}; //Return asii number of the first letter in str
function match(str,patt){return str.match(patt)};
function replace(str,find,rep,flag){flag!='i'?flag='':0;var r = new RegExp(find,"g"+flag);return str.replace(r,rep)}; //Returns a string that replaces all find with replace in str.Case sensitive
function search(str, find){return str.search(find)};
function split(str,str_sep,lim){return str.split(str_sep,lim)}; //Break a string into an array
function strmatch(str,find,flag){flag!='i'?flag='':0;var r = new RegExp(find,flag+'g');return str.match(r)==null?0:str.match(r).length};
function strlen(str){return str.length}; //Returns string lengths
function strpos(str,str2){return str.indexOf(str2)}; //Returns position of str2 in str in number
function strtolowercase(str){return str.toLowerCase()}; 
function strtouppercase(str){return str.toUpperCase()};
function strpad(str,len,pad){while(str.length<len){str+=pad;}return str.substr(0,len);}; //Pad to the right side of the string, to a new length of len characters. If str is shorter than len str is truncated	
function strsearch(str,find,flag){flag!='i'?flag='':0;var r = new RegExp(find,flag);return str.search(r)}; //Searches a str for a specified find, and returns the position of the match. reg is regular expression. "i" for case insensitive
function substr(str,start,length){if(start<0)start+=str.length;return str.substr(start,length)}; //Returns a string from str at the start and length
function trim(str){return str.replace(/^\s+|\s+$/gm,'')}; //Removes whitespace from both sides of a string.





/********************************************************************************************************
******************************************MATH***********************************************************
********************************************************************************************************/

function abs(n){return Math.abs(n)};
function acos(n,d){x=Math.acos(n);d=="deg"?x*=$_R2D:0;return x};
function asin(n,d){x=Math.asin(n);d=="deg"?x*=$_R2D:0;return x};
function atan(n,d){x=Math.atan(n);d=="deg"?x*=$_R2D:0;return x};
function bindec(s){return parseInt(s,2)};
function binhex(s){return parseInt(s,2).toString(16)};
function ceil(n){return Math.ceil(n)};
function cos(a,d){d=="deg"?a*=$_D2R:0;return Math.cos(a)};
function decbin(n){return parseInt(n).toString(2)};
function dechex(n){return parseInt(n).toString(16)};
function deg2rad(n){return n*$_D2R};
function exp(n){return Math.exp(n)};
function floor(n){return Math.floor(n)};
function fmod(t,n){return t%n};
function hexbin(s){return parseInt(s,16).toString(2)};
function hexdec(s){return parseInt(s,16)};
function log(n){return Math.log(n)};
function log10(n){return Math.log(n)/$_LN10};
function pow(b,e){return Math.pow(b,e)};
function rad2deg(n){return n*$_R2D};
function rand(m,x){if(arguments.length==2)return Math.floor(Math.random()*(x-m+1))+m;return Math.random()};
function round(n,d){return (n).toFixed(d)};
function sin(a,d){d=="deg"?a*=$_D2R:0;return Math.sin(a)};
function sqrt(n){return Math.sqrt(n)};
function tan(a,d){d=="deg"?a*=$_D2R:0;return Math.tan(a)};




	
/********************************************************************************************************
******************************************HTML***********************************************************
********************************************************************************************************/

//-------------------------------------------
//--------------------$----------------------
//-------------------------------------------

function $(selector){
	
	if(typeof selector=='string') selector=$_D.querySelectorAll(selector)
			
	if(Object.prototype.toString.call(selector)==='[object NodeList]' || selector[0])return selector
	
	
	return [selector]
};



//-------------------------------------------------
//--------------------Css--------------------------
//-------------------------------------------------

function css(selector){
	
	var elem=$(selector), len=elem.length, arg=arguments, argLen=arg.length, str=''
	
	for(var i=0;i<len;i++){
		for(var j=1;j<argLen;j+=2){
			str+=arg[j]+':'+arg[j+1]+';'
		}
		elem[i].style.cssText=str
		str=''
	}
};




//----------------------------------------
//-------------------Cstyle---------------
//----------------------------------------
	
function cstyle(selector,cssprop){
	var elem=$(selector)[0], value

    if ($_W.getComputedStyle){
		value=getComputedStyle(elem,null).getPropertyValue(cssprop)
		if(value.substr(-2,2)=='px') value=parseInt(value+.5)+'px'
         return value; 
    }
	else{
		var value=elem.currentStyle[cssprop];
		
		//Convert %,em,pt to px
		if (!/^\d+(%|em|pt)?$/i.test(value)) return value;
			var style = elem.style.left;
			var runtimeStyle = elem.runtimeStyle.left;
			elem.runtimeStyle.left = elem.currentStyle.left;
			elem.style.left = value || 0;
			value = elem.style.pixelLeft;
			elem.style.left = style;
			elem.runtimeStyle.left = runtimeStyle;
			return value+'px'
	}
};	




//---------------------------------------------
//--------------------Html---------------------
//----------------------------------------------

function html(selector,value,at){

	var pos={'before':'beforebegin','begin':'afterbegin','end':'beforeend','after':'afterend'},
	elem=$(selector), len=elem.length
	
	if(!value)return elem[0].innerHTML
	if(value=='inner'||value=='outer')return elem[0][value+'HTML']
	if(at=='inner'||at=='outer'){
		prop(selector,at+'HTML',value)
	}
	else{
		for(var i=0;i<len;i++){
			elem[i].insertAdjacentHTML(pos[at],value)
		}
	}
};





//---------------------------------------------
//----------------Positions--------------------	
//---------------------------------------------

function posleft(selector){return $_Position($(selector)[0],0).x};
function potop(selector){return $_Position($(selector)[0],0).y};
function posleftpage(selector){return $_Position($(selector)[0],1).x};
function postoppage(selector){return $_Position($(selector)[0],1).y};
function posleftrel(selector){var elem=$(selector)[0];return $_Position(elem,view).x-$_Position(elem.parentElement,view).x};	
function postoprel(selector){var elem=$(selector)[0];return $_Position(elem,view).y-$_Position(elem.parentElement,view).y};	

function $_Position(elem,page) {
	var scrollTop=0, scrollLeft=0,
    box = elem.getBoundingClientRect(), body = $_D.body, docElem = $_D.documentElement,
    clientTop = docElem.clientTop || body.clientTop || 0,
    clientLeft = docElem.clientLeft || body.clientLeft || 0
     
	if(page) scrollTop = $_W.pageYOffset || docElem.scrollTop || $_D.body.scrollTop
    if(page) scrollLeft = $_W.pageXOffset || docElem.scrollLeft || $_D.body.scrollLeft
	
	var top  = box.top +  scrollTop - clientTop, left = box.left + scrollLeft - clientLeft

    return { y: Math.round(top), x: Math.round(left) }
};




//---------------------------------------------
//----------------Page left/top----------------	
//---------------------------------------------

function pagetop(){return $_W.pageYOffset || $_D.documentElement.scrollTop || $_D.body.scrollTop || 0};
function pageleft(){ return $_W.pageXOffset || $_D.documentElement.scrollLeft || $_D.body.scrollLeft || 0};





//---------------------------------------------
//-----------------Prop------------------------
//---------------------------------------------

function prop(selector){
	
	var elem=$(selector), len=elem.length, arg=arguments, argLen=arg.length
	
	if(argLen==2) return elem[0][arg[1]]

	for(var i=0;i<len;i++){
		for(var j=1;j<argLen;j+=2){
			elem[i][arg[j]]=arg[j+1]
		}
	}
};





//-------------------------------------------
//--------------------Text-------------------
//-------------------------------------------

function text(selector,text){

	var elem=$(selector),textnode,nodes,i=0,j=0,f=1,val,pat=/^\s+$/
	
	if(!text){
		if(elem[0].hasChildNodes()){
			nodes=elem[0].childNodes, len=nodes.length
			for(j=0;j<len;j++){
				val=nodes[j].nodeValue
				if(nodes[j].nodeType==3&&!pat.test(val))return val
			}
		}
	}
	
	for(var len2=elem.length;i<len2;i++){
		if(elem[i].hasChildNodes()){
			nodes=elem[i].childNodes, len=nodes.length
			for(j=0;j<len;j++){
				val=nodes[j].nodeValue
				if(nodes[j].nodeType==3&&!pat.test(val)){nodes[j].nodeValue=text;f=0;break}
			}
		}
		else if(f){
			textnode=document.createTextNode(text)
			elem[i].appendChild(textnode)
			f=1
		}
	}
};



	
//--------------------------------------------------
//------------Widths and heights--------------------
//--------------------------------------------------

function height(selector,flag){return $_Dim(selector,flag,'top','bottom','Height')}
function width(selector,flag){return $_Dim(selector,flag,'left','right','Width')}

function $_Dim(selector,flag,topLeft,bottomRight,hw){
	var elem=$(selector)[0]
	
	if(flag=='i'){
		var padTL=cstyle(elem,'padding-'+topLeft), padBR=cstyle(elem,'padding-'+bottomRight)
		if(padTL.substr(-2,2)=='px' && padBR.substr(-2,2)=='px')
			return elem['client'+hw]-parseInt(padTL)-parseInt(padBR);
			return ie_hack(elem,flag,hw)
	}	
	
	if(flag=='m'){
		var marTL=cstyle(elem,'margin-'+topLeft), marBR=cstyle(elem,'margin-'+bottomRight)
		if(marTL.substr(-2,2)=='px' && marBR.substr(-2,2)=='px')
			return elem['offset'+hw]+parseInt(marTL)+parseInt(marBR);
			return ie_hack(elem,flag,hw)
	}	
	
	return flag=='p'?elem['client'+hw]:elem['offset'+hw]
	
	//IE8 hack inner/margin
	function ie_hack(elem,flag,hw){
		var tag={i:'<div id="cnefiwyewi" style="margin:0;padding:0;border:0;height:100%">',
		m:'<div id="cnefiwyewi"><div id="jtyotbnjg" style="margin:0;padding:0;border:0;float:left" >'},
		tagend={i:'</div>',m:'</div><div style="clear:both"></div></div>'},sum={},
		io={i:'innerHTML',m:'outerHTML'},newelem, cleanup, 
		
		//Save inner/outerHTML of elemnet
		old=elem[io[flag]]
		
		//Put new DIVs in the document
		elem[io[flag]]=tag[flag]+old+tagend[flag]
		
		//Get new element and save elements clientHeight/Width
		newelem=flag=='i'?$('#cnefiwyewi')[0]:$('#jtyotbnjg')[0]
		sum[flag]=newelem['client'+hw]
			
		//Clean up 
		cleanup=flag=='i'?elem:$('#cnefiwyewi')[0]
		cleanup[io[flag]]=old
		
		return sum[flag]
	}
};




/********************************************************************************************************
******************************************DATE***********************************************************
********************************************************************************************************/

//------------------------------------------
//---------------Date-----------------------
//------------------------------------------

function date(str,unix,t){
unix===undefined?t=new Date():t=new Date(unix)

//Declaration  j, w, n, Y, G, i, s, U....... $_d, $_m, $_o found in Init
var z=t.getTimezoneOffset(),s,h,n,i=0,len=str.length,sub,
p={j:t.getDate(),w:t.getDay(),n:t.getMonth(),Y:t.getFullYear(),G:t.getHours(),i:t.getMinutes(),s:t.getSeconds(),U:t.getTime(),sum:''}

//Rule Z, l, F, M, y, N
p.Z=z*-6e4;p.l=$_d[p.w];p.D=p.l.substr(0,3);p.F=$_m[p.n++];p.M=p.F.substr(0,3);p.y=p.Y.toString().substr(2,2);p.N=!p.w*7+p.w;

//Rule O, P
z>0?s="-":s="+";h=parseInt(z/60);h<0?h*=-1:0;h<10?h='0'+h:0;z%60?n='30':n='00';p.O=s+h+n;p.P=s+h+':'+n

//Rule g, a, A
p.g=p.G;if(p.G<11){p.a="am";p.A="AM"}else{p.a="pm";p.A="PM"};if(p.G>12)p.g=p.G-12;if(p.G==0)p.g=12;if(p.g==0)p.g++;

//Rule s. Zero pad seconds
if(p.s<10)p.s='0'+p.s;

//Rule H. Zero pad hours 24
p.G<10?p.H="0"+p.G:p.H=p.G;

//Rule h. Zero pad hours 12
p.g<10?p.h="0"+p.g:p.h=p.g;

//Rule m. Zero pad months
p.n<10?p.m="0"+p.n:p.m=p.n;

//Rule d. Zero pad date
p.j<10?p.d="0"+p.j:p.d=p.j;

//Rule S. st, nd, th
(p.j==1||p.j==21||p.j==31)?p.S=$_o[0]:(p.j==2||p.j==22)?p.S=$_o[1]:(p.j==3||p.j==23)?p.S=$_o[2]:p.S=$_o[3]


//Parse
for(;i<len;i++){
	sub=str.substr(i,1);
	
	sub=='\\'?p.sum+=sub=str.substr(++i,1):
	/^[dDjlNSwFmMnYyGaAgisZOPHUh]+$/.test(sub)?p.sum+=p[sub]:
	/^[ :,.\-/]+$/.test(sub)?p.sum+=sub:
	sub=='c'?p.sum+=date('Y-m-d\\TH:i:sP',unix):
	sub=='r'?p.sum+=date('D, d M Y H:i:s O',unix):0
	
}
return p.sum.toString()
};




//------------------------------------------
//---------------Time-----------------------
//------------------------------------------

function time(){
	var d = new Date()
	return d.getTime()
};




//------------------------------------------
//---------------Utc-----------------------
//------------------------------------------

function utc(){
	var d=new Date()
	return d.getTime()+d.getTimezoneOffset()*6e4
};






/********************************************************************************************************
******************************************EFFECTS********************************************************
********************************************************************************************************/


//------------------------------------------------------
//------------------Fade in------------------------------
//------------------------------------------------------

	function fadein(selector,msec,func,arg){
	
		css(selector,'opacity',0,'visibility','visible')
		var startVal=0
		var delta=msec/40
		
		var time=$_W.setInterval(callback,delta)
		
		function callback(){
			if(startVal>=1){
				$_W.clearInterval(time)
				if(func) func.apply($_W,arg)
			}
			else{
			startVal+=0.025
			css(selector,'opacity',startVal ,'filter', 'alpha(opacity='+startVal*100+')')
			
			}
		}
	};


	
	
	
//------------------------------------------------------
//------------------Fade out------------------------------
//------------------------------------------------------

	function fadeout(selector,msec,func,arg){
	
		var startVal=1
		var delta=msec/40
		
		var time=$_W.setInterval(callback,delta)
		
		function callback(){
			if(startVal<=0){
				$_W.clearInterval(time)
				css(selector,'opacity',1,'visibility','hidden')
				if(func) func.apply($_W,arg)
			}
			else{
			startVal-=0.025
			css(selector,'opacity',startVal ,'filter', 'alpha(opacity='+startVal*100+')')
			
			}
		}
	};
	

	
	
//------------------------------------------------------
//------------------Toggle------------------------------
//------------------------------------------------------

function toggle(selector, display){

	var elem=$(selector), len=elem.length
	
	if(!display)var display='block'
	
	for(var i=0;i<len;i++){
		
		if(elem[i].style.display!=''){
			
			elem[i].style.display='';
		}

		else{
			elem[i].style.display=display;
		}
	}
};
	

	
		
//------------------------------------------------------
//------------------Show/Hide/Visible-------------------
//------------------------------------------------------

	function show(selector,val){(!val)?val=';':0;css(selector,'display:'+val)};
	function hide(selector){css(selector,'display:none;')};
	function visible(selector,bool){(bool)?bool='visible':bool='hidden';css(selector,'visibility:'+bool+';')};
	


/********************************************************************************************************
******************************************ARRAY**********************************************************
********************************************************************************************************/


//---------------------------------------------------
//-----------------Array-----------------------------
//---------------------------------------------------

function array(){
	var arg=arguments, argLen=arg.length, arr=[]
	
	if(argLen==0)arr._()
	
	for (var i=0,j=0;i<argLen;i++,j++){
		if(arg[i+1]!=="=>"){
			arr._(j,arg[i])
		}
		else{
			arr._(arg[i],arg[i+2])
			i+=2
		}
	}
	
	return arr
};



//-----------------------------------------------------
//----------------------asort--------------------------
//-----------------------------------------------------


function asort(arr,flag){
	
	var arrTemp=[], len=arr.length

	//Add indexes to value. Seperated with $AS$ in the array
	for(var i=0;i<len;i++) arr[i]+="$AS$"+i
				
	//Sort the array
	sort(arr,flag,1)
			
	//Put sorted indexes as value and add indexes separated by $AS$ 		
	for(i=0;i<len;i++) arrTemp[i]=arr[i].split("$AS$")[1]+"$AS$"+i
	
	//Sort new array numeric. 
	sort(arrTemp,"num",1)
	
	//Put sorted indexes in keys
	for(var keys in  arr.key){arr.key[keys]=arrTemp[arr.key[keys]].split("$AS$")[1]}
	
	//Remove $AS$ separator from value
	for(i=0;i<len;i++) arr[i]=arr[i].split("$AS$")[0]
	
	//Store arr by ref
	arr.push(0)
	arr.pop()
};





//---------------------------------------------------
//----------------------Dump---------------------
//---------------------------------------------------
	
function dump(arr){
	if(!isarray(arr)) throw($_e[0]+' in DUMP')
	var len=arr.length, i=0, arrKey=[]
	
	for(var key in arr.key){
		arrKey[arr.key[key]]=key
	}
	$_D.writeln('<br/>ARRAY<br/>')
	for(;i<len;i++){
		if(arrKey[i]===undefined) arrKey[i]='{empty}'
		$_D.writeln('['+i+'] '+arrKey[i]+' => '+arr[i]+'<br/>')
	}
};
	
	

	
//---------------------------------------------------
//----------------------foreach---------------------
//---------------------------------------------------

function foreach(arr,tok,func){
	if(!isarray(arr)) throw($_e[0]+' in FOREEACH')
	
	if(tok=="=>"){
		for(var keys in arr.key){
			if(func(arr.key[keys],keys)=='break')return false
		}
	}
	
	else{
		for(var i=0,len=arr.length;i<len;i++){
			if(tok(i)=='break') return false
		}
	}
	return true
};

	
		

//-------------------------------------------------
//--------------haskey-----------------------------
//------------------------------------------------

function haskey(arr){for(var keys in  arr.key){return true};return false}





//------------------------------------------------------
//-------------------In arrray-------------------------
//-----------------------------------------------------
	
function inarray(val,arr) {
	if(indexof(arr,val)==-1)return false
	return true
};
	
	
	
	
//-------------------------------------------------------
//----------------indexof--------------------------------
//-------------------------------------------------------

function indexof(arr,val){

	if(arr.indexOf)	return arr.indexOf(val)
			
	var i, len=arr.length

	for (i=0; i < len; i++) {
		if (arr[i] === val) return i
		
	}
	return -1
};



//----------------------------------------------------
//-----------------Key exists-------------------------
//---------------------------------------------------

function keyexists(key,arr){
	
	for(var keys in arr.key){
		if(keys===key) return true
	}
	return false
};


	

//---------------------------------------------------
//-------------------Merge---------------------------
//---------------------------------------------------

function merge(arr,arr2){
	var  arr2Len=arr2.length, arrLen=arr.length
		
	for (var keys in arr2.key)arr.key[keys]=arr2.key[keys]+arrLen
		
	for (var i=0;i<arr2Len;i++)arr.push(arr2[i])
	
	return arr.length	
};		
		

		

//------------------------------------------------------
//----------------------Pop---------------------------
//------------------------------------------------------

function pop(arr){

	var lastIndex=arr.length-1
	
	for (var keys in arr.key){
		if(arr.key[keys]==lastIndex)delete arr.key[keys]
	}

	return arr.pop()
};
		
		


//-----------------------------------------------------
//----------------------Push---------------------------
//-----------------------------------------------------

function push(){
	var arg=arguments, argLen=arg.length, arr=arg[0], arrLen=arr.length
		
	for (var i=1,j=arrLen;i<argLen;i++,j++){
		if(arg[i+1]!=="=>"){
			arr.push(arg[i])
		}
		else{
			arr.push(arg[i+2])
			arr.key[arg[i]]=j
			i+=2
		}
	}
	return arr.length	
};		
	


	
//------------------------------------------------------
//----------------------Shift---------------------------
//------------------------------------------------------

function shift(arr){

	for (var keys in arr.key){
		arr.key[keys]--
		if(arr.key[keys]==-1)delete arr.key[keys]
	}
	
	return arr.shift()
	
};



	
//-------------------------------------------------------
//------------------------Sort---------------------------	
//------------------------------------------------------
	
function sort(arr,flag,haskey){
	
	if(!flag)var flag="nor"
	if(flag=="num" && haskey){return arr.sort(function(a,b){a=a.split("$AS$")[0];b=b.split("$AS$")[0];return a-b})}
	if(flag=="rev_num" && haskey){return arr.sort(function(a,b){a=a.split("$AS$")[0];b=b.split("$AS$")[0];return b-a})}
	
	if(flag=="num"){arr.sort(function(a,b){return a - b})};
	if(flag=="rev_num"){arr.sort(function(a,b){return b - a})};
	if(flag=="rev_i"){arr.sort(function(a,b){a=a.toString().toLowerCase();b=b.toString().toLowerCase();a==b?x=0:a<b?x=1:x=-1;return x})};
	if(flag=="i"){arr.sort(function(a,b){a=a.toString().toLowerCase();b=b.toString().toLowerCase();a==b?x=0:a>b?x=1:x=-1;return x})};
	if(flag=="rnd"){arr.sort(function(){return 0.5-Math.random()})};
	if(flag=="rev_nor")arr.sort().reverse()
	if(flag=="rev") arr.reverse()
	if(flag=="nor") arr.sort()	
};




//---------------------------------------------
//----------------Slice-----------------------
//--------------------------------------------

function slice(arr,start,end){
	if(isstring(arr))return arr.slice(start,end)
	
	if(!end)end=arr.length
	
	var arr2=arr.slice(start,end)
	arr2._()
	
	for(var keys in  arr.key){
		var index=arr.key[keys]
		if(index>=start && index<=end)arr2.key[keys]=index-start

	}
	
	return arr2
};

	
	
	
//---------------------------------------------
//----------------Splice-----------------------
//--------------------------------------------

function splice(arr,start,number){
	var arg=arguments, argLen=arg.length, arrT=array(start,number),
	keys, keys2, val, arrOut, keyOffset, i=3, j=0
		
		//Put arguments in new temp array
		for (;i<argLen;i++,j++){
			if(arg[i+1]!=="=>"){
				arrT[j+2]=arg[i]
			}
			else{
				arrT[j+2]=arg[i+2]
				arrT.key[arg[i]]=j+start
				i+=2
			}
		}
		
		keyOffset=arrT.length-number-2
		
		//Update keys in arr
		for(var keys in arr.key){
			val=arr.key[keys]
			if(val>start&&val<start+number){delete arr.key[keys]}
			else if(val>=start) arr.key[keys]+=keyOffset
		}
		
		//Splice
		arrOut=arr.splice.apply(arr,arrT)
		
		//Update added keys from temp array
		for(var keys2 in arrT.key){
			arr.key[keys2]=arrT.key[keys2]
		}
	
	return arrOut
};





//------------------------------------------------------
//------------------Unshift-----------------------------
//------------------------------------------------------

function unshift(){
	var arg=arguments, argLen=arg.length, arr=arg[0]
	
	for(var i=1,j=0;i<argLen;i++,j++)if(arg[i+1]==="=>")i+=2
			
	
	for (var keys in arr.key)arr.key[keys]+=j
	
		
	for (i=argLen-1,j--;i>=1;i--,j--){
		if(arg[i-1]!=="=>"){
			arr.unshift(arg[i])
		}
		else{
			arr.unshift(arg[i])
			arr.key[arg[i-2]]=j
			i-=2
		}
	}
	return arr.length	
			
};




/********************************************************************************************************
******************************************AJAX**********************************************************
********************************************************************************************************/

//-------------------------------
//-------------Server------------
//-------------------------------

function server(url,dataArr,func){

	var str="", success=false, text
	
	if(isarray(dataArr)){
		for(var keys in dataArr.key){
			str+=encodeURIComponent(keys)+"="+encodeURIComponent(dataArr._(keys))+"&"
		}
	
		str=str.slice(0,str.length-1)
	}

	 if ($_W.XMLHttpRequest){
		var xmlhttp=new XMLHttpRequest();
		
		xmlhttp.onreadystatechange=function(){
			if (xmlhttp.readyState==4){
				if(xmlhttp.status>=200&&xmlhttp.status<300)success=true
				text=xmlhttp.responseText
				func($_Ajax2arr(text),success,xmlhttp.status,text)
			}
		}
		
		xmlhttp.open("POST",url,true);
		xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		xmlhttp.send(str);
	}
	
		 
 };
 
 
 
 
 
//--------------------------------
//-----------$_Ajax2arr-----------
//--------------------------------
 
 function $_Ajax2arr(str){
	var arr=array(), partArr=str.split('&'), len=partArr.length, secArr
	
	for(var i=0;i<len;i++){
		secArr=partArr[i].split('=')
		arr._(decodeURIComponent(secArr[0]),decodeURIComponent(secArr[1]))
	}

	return arr
};





/********************************************************************************************************
******************************************XML************************************************************
********************************************************************************************************/

//--------------------------------------
//----------------Load------------------
//--------------------------------------

function load(url,selector){return xml(loadxmlfile(url),selector)[0].text[0]};




//--------------------------------------
//-------------Loadtextfile--------------
//--------------------------------------

function loadtextfile(url){return $_Loadfile(url).responseText};





//--------------------------------------
//-------------Loadxmlfile--------------
//--------------------------------------

function loadxmlfile(url){return $_Loadfile(url).responseXML};





//--------------------------------------
//-------------Loadxmlstr---------------
//--------------------------------------

function loadxmlstr(str){
	var ie=true
	
	//Check if it is IE
	try {new ActiveXObject("Microsoft.XMLDOM")}
	catch(e){if(e)ie=false}
	
	//IE code
	if(ie){
		var xmlDoc=new ActiveXObject("Microsoft.XMLDOM")
		xmlDoc.async=false;
		xmlDoc.loadXML(str)
		return xmlDoc
	}
	//Other than IE
	else if(window.DOMParser && !ie){
		var parser=new DOMParser();
		return parser.parseFromString(str,"text/xml");
	}	
	return false
};




//--------------------------------------
//-----------------Xml------------------
//--------------------------------------

function xml(xmlDoc,selector){

	var  path=css2xpath(selector), arr=[], i=0, nodes, result, ie=false

	// code for IE
	try {xmlDoc.selectNodes} catch(e){if(e)ie=true}
	
	if (ie){
		xmlDoc.setProperty("SelectionLanguage","XPath");
		nodes=xmlDoc.selectNodes(path);
		return $_Nod(nodes)
	}

	// code for Chrome, Firefox, Opera, etc.
	else if (document.implementation && document.implementation.createDocument){
		nodes=xmlDoc.evaluate(path, xmlDoc, null, XPathResult.ANY_TYPE, null);
		result=nodes.iterateNext();

		while (result){
		  arr[i++]=result
		  //[0].nodeValue;
		 
		  result=nodes.iterateNext();
		 }
	}
	return $_Nod(arr)
};




//--------------------------------------
//-------------$_Loadfile---------------
//--------------------------------------

function $_Loadfile(url){
	var xmlhttp
	
	if (window.XMLHttpRequest){
		// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else{
		// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	xmlhttp.open("GET",url,false);
	try {xmlhttp.responseType="msxml-document"} catch(err) {} // Helping IE
	xmlhttp.send("");
	
return xmlhttp
};



	
//--------------------------------------
//----------------$_Nod-----------------
//--------------------------------------

function $_Nod(nodelist){
	var len=nodelist.length, arr=[], i=0
	
	for(;i<len;i++){
	
		var att=nodelist[i].attributes, lenA=att.length, arrAttName=[], arrAttVal=[], j=0
			
			for(;j<lenA;j++){
				arrAttName[j]=att[j].nodeName
				arrAttVal[j]=att[j].value||att[j].nodeValue
			}
				
		var chi=nodelist[i].childNodes, lenC=chi.length, arrText=[], arrCdata=[], arrChild=[], k=0, l=0, j=0,
			val,pat=/^\s+$/,type
			
			for(;j<lenC;j++){
				val=chi[j].nodeValue
				type=chi[j].nodeType
				
				if(type==1)arrChild[l++]=chi[j].nodeName
				if(type==3&&!pat.test(val))arrText[k++]=val
				if(type==4)arrCdata[l++]=val
			}
				
	arr[i]={attribute:arrAttName,avalue:arrAttVal,text:arrText,cdata:arrCdata,child:arrChild,tagname:nodelist[i].nodeName}
	}
	return arr
};

	
	
/** version 0.1 2009-04-30
 * @author      Andrea Giammarchi
 * @license     Mit Style License
 * @project     http://code.google.com/p/css2xpath/
 */css2xpath=(function(){var b=[/\[([^\]~\$\*\^\|\!]+)(=[^\]]+)?\]/g,"[@$1$2]",/\s*,\s*/g,"|",/\s*(\+|~|>)\s*/g,"$1",/([a-zA-Z0-9\_\-\*])~([a-zA-Z0-9\_\-\*])/g,"$1/following-sibling::$2",/([a-zA-Z0-9\_\-\*])\+([a-zA-Z0-9\_\-\*])/g,"$1/following-sibling::*[1]/self::$2",/([a-zA-Z0-9\_\-\*])>([a-zA-Z0-9\_\-\*])/g,"$1/$2",/\[([^=]+)=([^'|"][^\]]*)\]/g,"[$1='$2']",/(^|[^a-zA-Z0-9\_\-\*])(#|\.)([a-zA-Z0-9\_\-]+)/g,"$1*$2$3",/([\>\+\|\~\,\s])([a-zA-Z\*]+)/g,"$1//$2",/\s+\/\//g,"//",/([a-zA-Z0-9\_\-\*]+):first-child/g,"*[1]/self::$1",/([a-zA-Z0-9\_\-\*]+):last-child/g,"$1[not(following-sibling::*)]",/([a-zA-Z0-9\_\-\*]+):only-child/g,"*[last()=1]/self::$1",/([a-zA-Z0-9\_\-\*]+):empty/g,"$1[not(*) and not(normalize-space())]",/([a-zA-Z0-9\_\-\*]+):not\(([^\)]*)\)/g,function(f,e,d){return e.concat("[not(",a(d).replace(/^[^\[]+\[([^\]]*)\].*$/g,"$1"),")]")},/([a-zA-Z0-9\_\-\*]+):nth-child\(([^\)]*)\)/g,function(f,e,d){switch(d){case"n":return e;case"even":return"*[position() mod 2=0 and position()>=0]/self::"+e;case"odd":return e+"[(count(preceding-sibling::*) + 1) mod 2=1]";default:d=(d||"0").replace(/^([0-9]*)n.*?([0-9]*)$/,"$1+$2").split("+");d[1]=d[1]||"0";return"*[(position()-".concat(d[1],") mod ",d[0],"=0 and position()>=",d[1],"]/self::",e)}},/:contains\(([^\)]*)\)/g,function(e,d){return"[contains(string(.),'"+d+"')]"},/\[([a-zA-Z0-9\_\-]+)\|=([^\]]+)\]/g,"[@$1=$2 or starts-with(@$1,concat($2,'-'))]",/\[([a-zA-Z0-9\_\-]+)\*=([^\]]+)\]/g,"[contains(@$1,$2)]",/\[([a-zA-Z0-9\_\-]+)~=([^\]]+)\]/g,"[contains(concat(' ',normalize-space(@$1),' '),concat(' ',$2,' '))]",/\[([a-zA-Z0-9\_\-]+)\^=([^\]]+)\]/g,"[starts-with(@$1,$2)]",/\[([a-zA-Z0-9\_\-]+)\$=([^\]]+)\]/g,function(f,e,d){return"[substring(@".concat(e,",string-length(@",e,")-",d.length-3,")=",d,"]")},/\[([a-zA-Z0-9\_\-]+)\!=([^\]]+)\]/g,"[not(@$1) or @$1!=$2]",/#([a-zA-Z0-9\_\-]+)/g,"[@id='$1']",/\.([a-zA-Z0-9\_\-]+)/g,"[contains(concat(' ',normalize-space(@class),' '),' $1 ')]",/\]\[([^\]]+)/g," and ($1)"],c=b.length;return function a(e){var d=0;while(d<c){e=e.replace(b[d++],b[d++])}return"//"+e}})();





/********************************************************************************************************
****************************************GENERAL**********************************************************
********************************************************************************************************/

function decode(str,type){if(type=='RFC3986')return decodeURIComponent(str);return decodeURI(str)};
function die(str){throw new Error (str)};
function encode(str,type){if(type=='RFC3986')return encodeURIComponent(str);return encodeURI(str)};
function floating(str){return parseFloat(str)};
function integer(str,radix){return parseInt(str,radix)};
function loop(times,func){for (var i=0;i<times;i++) if(func(i)=='break')return false};
function redirect(url,bool){if(bool)location.assign(url);if(!bool)location.replace(url)};
function reload(bool){loacation.reload(bool)};
function setwindow(win){win?$_W=win:$_W=window;$_D=$_W.document};
function string(val,radix){return val.toString(radix)};	



/********************************************************************************************************
******************************************EVENT**********************************************************
********************************************************************************************************/


//-------------------------------------
//-----------------On------------------
//-------------------------------------

function on(type,selector,func,passArg,cap){
	
	var argLen=arguments.length, elem=$(selector), len=elem.length

	if(argLen==3){passArg=[],cap=false}
	if(argLen==4&&isarray(passArg))cap=false
	if(argLen==4&&isbool(passArg)){cap=passArg;passArg=[]}
		
	if(addEventListener){
		for(var i=0;i<len;i++){
		elem[i].addEventListener(type,function(){func.apply($_W,passArg)},cap)
		}
	}
	else if(attachEvent){
		for(var i=0;i<len;i++){
			elem[i].attachEvent('on'+type,function(){func.apply($_W,passArg)})
		}
	}
	else return -1
};





//-------------------------------------
//-----------------Off-----------------
//-------------------------------------

function off(selector,type,func){
	
	var elem=$(selector), len=elem.length
	
	if(addEventListener){
		for(var i=0;i<len;i++){
			elem[i].removeEventListener(type,func)
		}
	}
	else if(attachEvent){
		for(var i=0;i<len;i++){
			elem[i].detachEvent('on'+type,func)
		}
	}
	else return -1
};





//-------------------------------------
//-----------------Key-----------------
//-------------------------------------

function key(str){

	var e=event, m={alt:e.altKey,ctrl:e.ctrlKey,shift:e.shiftKey,code:e.which || e.keyCode}

	return m[str.toLowerCase()]
};




//-------------------------------------
//-----------------Mouse---------------
//-------------------------------------

function mouse(str){
	var butt=['left','middle','right'], e=event
		
	//If IE8 or less
	if (document.all && !document.addEventListener){
		butt[1]='left';butt[4]='middle'}
			
	var m={
	x:e.clientX,y:e.clientY,button:butt[e.button],
	xp:e.pageX,yp:e.pageY}
	return m[str.toLowerCase()]
};




//-------------------------------------
//-----------------Ready--------------
//-------------------------------------

function ready(func){

	// If the browser ready event has already occured
	if ($_D.readyState === "complete") 
            return func()
	
	// If eventlistener
	if ($_D.addEventListener){
		if(!$_D.addEventListener("DOMContentLoaded", func, false))
			// A fallback to onload,
			$_W.addEventListener("load", func, false)

	}
	//IE8 hack
	else if ($_D.attachEvent){
		if(!$_D.attachEvent("onreadystatechange", func))
			// A fallback to onload
			$_W.attachEvent("onload", func)
	}
	else return -1
}





//-------------------------------------
//-----------------Target--------------
//-------------------------------------

function target(str){
	str?0:str='target'
	var e=event, m={
	target:e.target||e.srcElement,current:e.currentTarget,related:e.relatedTarget}
	
	return [m[str.toLowerCase()]]
};




//--------------------------------------
//---------Timer/Timeroff/Wait----------
//--------------------------------------

function timer(msec,func,arg){return $_W.setInterval(function(){func.apply($_W,arg)},msec)};

function timeroff(point){$_W.clearInterval(point)||$_W.clearTimeout(point)};

function wait(msec,func,arg){return $_W.setTimeout(function(){func.apply($_W,arg)},msec)};




/********************************************************************************************************
******************************************COOKIE*********************************************************
********************************************************************************************************/



//-------------------------------------------------------
//-------------------Cookie -----------------------------
//-------------------------------------------------------

function cookie(name,value,days,path,domain,secure) {
	var expires="";
	
	if (days){
		var date = new Date();
		date.setTime(date.getTime()+(days*864e5));
		expires = "; expires="+date.toGMTString();
	}
	
	if(value){
		$_D.cookie = name+"="+value+expires+
		( ( path ) ? ';path=' + path : '; path=/' ) + 
		( ( domain ) ? ';domain=' + domain : '' ) +
		( ( secure ) ? ';secure' : '' );
	return true
	}

	if(name) {
		var cookArr=$_D.cookie.split(';'), cookSec, len=cookArr.length
		
		for(var i=0;i<len;i++){
			cookSec=cookArr[i].split('=')
			if (cookSec[0]==name||cookSec[0]==' '+name) return cookSec[1];
		}
	}
	return -1;
};




//-------------------------------------------------------
//-------------------Remove Cookie ----------------------
//-------------------------------------------------------

function removecookie(name){cookie(name,1,-1)};




/********************************************************************************************************
******************************************IS TEST********************************************************
********************************************************************************************************/

function isarray(a){if(Object.prototype.toString.call(a)==='[object Array]')return true;return false};
function isstring(a){if(typeof a=="string")return true;return false};
function isnum(a){if(typeof a=="number")return true;return false};
function isnull(a){if(a===null)return true;return false};
function isobj(a){if(typeof a=="object")return true;return false};
function isbool(a){if(typeof a=="boolean")return true;return false};




